package db.tables.reference;

import java.sql.SQLException;
import java.util.ArrayList;

import org.hsqldb.Types;

import db.DBObject;
import db.tables.DBActivityTable;
import db.tables.DBUserTable;

public class DBIsActiveTable extends DBObject {
	public static final String TABLE_NAME = "is_active";

	public static final String IS_ACTIVE_ID_COL = TABLE_NAME + "_id",
			ACTIVITY_ID_COL = DBActivityTable.ACTIVITY_ID_COL,
			USER_ID_COL = DBUserTable.USER_ID_COL,
			START_DATE_COL = "start_date", END_DATE_COL = "end_date";

	public DBIsActiveTable() throws ClassNotFoundException, SQLException {
		super(TABLE_NAME, new Object[][] {
				{ IS_ACTIVE_ID_COL, Types.BIGINT, SQL_IDENTITY_PRIMARY_KEY,"" },
				{ ACTIVITY_ID_COL, Types.BIGINT, SQL_NOT_NULL, "" },
				{ USER_ID_COL, Types.BIGINT, SQL_NOT_NULL, "" },
				{ START_DATE_COL, Types.DATE, SQL_NOT_NULL, "" },
				{ END_DATE_COL,	Types.DATE,  getSQLCheckEndDate()
					+getSQLForeignKeyReference(DBActivityTable.TABLE_NAME,ACTIVITY_ID_COL)
					+getSQLForeignKeyReference(DBUserTable.TABLE_NAME,USER_ID_COL),	"" } });
	}
	
	public ArrayList<ArrayList<String>> getSimilarUsers(){
		ArrayList<ArrayList<String>> result=new ArrayList<ArrayList<String>>();
		//usr.is_active_id,usr.activity_id,usr.user_id,usr.start_date,usr.end_date
		return result;
	}
	
	public ArrayList<ArrayList<Object>> getArrayListByUserID(Long user_id){
		return getReferenceTableJoin(tableName, DBActivityTable.TABLE_NAME, 
				getAbsoluteColumn(ACTIVITY_ID_COL), 
				getAbsoluteColumn(DBActivityTable.TABLE_NAME, DBActivityTable.ACTIVITY_ID_COL), 
				getAbsoluteColumn(USER_ID_COL),user_id);
	}
}
